import React from 'react'
import { Toast } from 'antd-mobile'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { actions as newsActionCraetors } from '../../redux/modules/user'
import config from '../../../config';
import './index.less';

class Index extends React.PureComponent {

  static contextTypes = {
    router: React.PropTypes.object.isRequired
  }


  componentDidMount() {
    const id = this.props.params.id
    this.fetchDetail(id)
    this.addView(id)
  }

  render() {

    return <section className="inner-page">

    </section>
  }

  fetchDetail(id) {
    this.props.actions.fetchDetail({ id }).then(json => {
      console.log(json)
    })
  }

  addView(id) {
    this.props.actions.addView({ id }).then(json => {
      console.log(json)
    })
  }

}

const stateToProps = state => ({
  ...state.news
})

const dispatchToProps = dispatch => ({
  actions: bindActionCreators(newsActionCraetors, dispatch)
})

export default connect(stateToProps, dispatchToProps)(Index);
